Skip to content

BUG: Use HashableT rather than Hashable to improve compat #154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 20, 2022

Conversation

bashtage
Copy link
Contributor

Use HashableT so that any hashable object can be use in a list or iterator

Use HashableT so that any hashable object can be use in a list or iterator
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thannks @bashtage

@Dr-Irv Dr-Irv merged commit d0601f3 into pandas-dev:main Jul 20, 2022
@@ -611,7 +612,7 @@ class DataFrame(NDFrame, OpsMixin):
def set_index(
self,
keys: Union[
Label, Series, Index, np.ndarray, Iterator[Hashable], List[Hashable]
Label, Series, Index, np.ndarray, Iterator[HashableT], List[HashableT]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the Iterator wouldn't have needed the TypeVar:

from typing import Iterator, Hashable

def test(x: Iterator[Hashable]):
    ...

def iter() -> Iterator[str]:
    ...

test(iter())

@bashtage bashtage deleted the improve-set-index branch July 20, 2022 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: set_index rejects List[str]
3 participants